package org.example.springbootwebexample.mapper;



import org.apache.ibatis.annotations.*;
import org.example.springbootwebexample.pojo.Emp;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {


//    @Select("select count(*) from emp")
//    Long count();
//
//
//    @Select("select * from emp limit #{start}, #{pageSize}")
//    List<Emp> list(Integer start, Integer pageSize);


    //模糊分页查询
    public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

    //根据id 删除员工
    void delete(List<Integer> ids);

    //新增员工
    @Insert("insert into emp (username,name, gender, image, job, entrydate, dept_id,create_time, update_time) VALUE " +
            "(#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})")
    void insert(Emp emp);

    //根据id 查询员工数据
    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    //更新员工数据
    void update(Emp emp);


    //员工登录
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getEmpByUsernameAndPassword(Emp emp);


    @Delete("delete from emp where dept_id = #{id}")
    void deleteByDeptId(Integer id);

}
